Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
Getting status of 400 - {"error":"invalid_grant"} On Authentication

I created my own website (www.luig.us). I create a basic IDE for SQL server to teach kids SQL, DML only.

It requires the user to enter an username and password at the beginning to get an token to use the service.

On local, everything works fine, but when I put it on my site, hosted by go-daddy, I will get the same message every time and I don't have a clue why.

{"error":"invalid_grant"}

This is my java script code - look for Authorize. Any help is appreciated. I followed this article closely https://www.c-sharpcorner.com/UploadFile/736ca4/token-based-authentication-in-web-api-2/



function Authorize() {
    let bearer = "Basic Q01JUzMwOERTMzA4OndlYkFQSQ=="
    var email = document.getElementById("email").value;
    var password = document.getElementById("password").value;
    var userNameAndPasswordFilled = (email != "" && password != "");
    if (!userNameAndPasswordFilled) {
        $("#formError").show('fast');
    }
    else {
        var bodyOfRequest = {
            grant_type: "password",
            username: email,
            password: password
        };
        $.ajax({
            type: "POST",
            url: uriManager.access,
            beforeSend: function (request) {
                request.setRequestHeader("Authorization", bearer);
            },
            data: bodyOfRequest,
            success: function (response) {
                sessionStorage.setItem(programKeyWords.BearerToken, response.access_token);
                $('#LogonModal').modal('hide');
            },
            error: function (response) {
                $("#formError").show('fast');
            }
        });
    }
}


over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

I can't say much without more information but first thing I would check is if you actually have users in your database (or whatever oauth you're using). The error you're getting can likely be caused if you don't actually have a user with that username and password in your oauth database.

The endpoint you're using for uriManager.access is where you have to check if that user actually exists.

over 4 years ago · Santiago Trujillo Denunciar

0

The problem wasn't with the code. The problem was with:

  1. The connection string. It was not correct.
  2. I was encrypting the username and password and it wasn't matching correctly because of special characters

What I did to fix it.

  1. fixed the connection string
  2. fixed the algorithm to store a hash instead of string.
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda